#include <iostream>
#include <algorithm>
#include <string>
#include <cctype>
using namespace std;
const int N = 110;
int a[N]; 

int main()
{
	int n,x;
	cin >> n >> x;
	int t;
	int i = 0;
    while(cin >> t)
    {
    	if(t%x == 0)
    	continue;
    	a[i] = t;
    	i++;
	}
	int n = i;
	sort(a,a+i);
	string ret = "";
	for(int i = 0;i<n;i++)
	{
		if(a[i] >='A' && a[i] <= 'Z')
		{
			ret += char(a[i]);
		}
		else
		ret += a[i];
	}
	cout << ret << endl;
   
	return 0;
}
